package com.guc.md

import android.app.Dialog
import android.os.Bundle
import android.view.View
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialogFragment

/**
 * Created by guc on 2021/5/27.
 * Description：实现全屏的BottomSheet展示效果
 */
class FullSheetDialogFragment : BottomSheetDialogFragment() {
    private lateinit var mBehavior: BottomSheetBehavior<View>
    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        val dialog = super.onCreateDialog(savedInstanceState)
        val view = View.inflate(context, R.layout.dialog_bs, null)
        dialog.setContentView(view)
        mBehavior = BottomSheetBehavior.from(view.parent as View)
        return dialog
    }

    override fun onStart() {
        super.onStart()
        mBehavior.state = BottomSheetBehavior.STATE_EXPANDED
    }

    fun doclick(v: View) {
        mBehavior.state = BottomSheetBehavior.STATE_HIDDEN
    }
}